/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.scuecsz.view.mbean.common;

import java.sql.SQLException;
import org.scuecsz.model.bussiness.RegisterLoginModel;
import org.scuecsz.model.to.ADMIN;
import org.scuecsz.model.to.USER_MAIN;
import org.scuecsz.view.utils.FaceUtil;

/**
 *
 * @author Administrator
 */
public class LogonMbean extends DefaultMbean {

    private String userID;
    private String password;
    private String msg;


    public String userlogonAction() {
        String rs = null;
        if (vc.isVerifyCode(vCode, true)) {
            try {
                msg = null;
                USER_MAIN userMain = RegisterLoginModel.login(userID);
                msg = RegisterLoginModel.loginRightCheck(userMain, password);
                if (null == msg) {
                    FaceUtil.setSessionAttribute("USER", userMain);
                    rs = "success";
                }else{
                   newVCodeActon();
                }
            } catch (SQLException ex) {
            } catch (Exception ex) {
            }
        } else {
            msg="验证码错误";
            newVCodeActon();
        }
        System.out.println("msg" + msg);
        return rs;
    }

    public String admlogonAction() {
        String rs = null;
        if (vc.isVerifyCode(vCode, true)) {
            try {
                msg = null;
                ADMIN admin = RegisterLoginModel.admlogin(userID);
                msg = RegisterLoginModel.adminRightCheck(admin, password);
                if (null == msg) {
                    FaceUtil.setSessionAttribute("USER", admin);
                    rs = "success";
                }else{
                   newVCodeActon();
                }
            } catch (SQLException ex) {
            } catch (Exception ex) {
            }
        } else {
            msg="验证码错误";
            newVCodeActon();
        }
        System.out.println("msg" + msg);
        return rs;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUserID() {
        return userID;
    }

    public void setUserID(String userID) {
        this.userID = userID;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }



}
